package test;

/**
 * 测试内存分配
 */
public class MemoryTest1 {
    public static void main(String[] args) {
        System.out.println(Runtime.getRuntime().freeMemory() / 1024 / 1024 + "MB");
        Object o = new Object[99999999]; //Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        System.out.println(Runtime.getRuntime().freeMemory() / 1024 / 1024 + "MB");
    }
}
